package com.edevp.common.web.interceptor;

import com.edevp.common.core.util.session.SessionUtil;
import org.slf4j.MDC;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 扩展属性
 * @author lean
 * @date 2022-07-06 4:49 PM
 **/
public class LogbackInterceptor implements HandlerInterceptor {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		MDC.clear();
		MDC.put("request_uri",SessionUtil.getCurrentRequestURI());
		MDC.put("client_ip", SessionUtil.getClientIpAddr());
		MDC.put("user_name", "张三");

		return true;
	}
}
